package com.aiju.common.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 数据库操作类
 *
 * @author Administrator
 */
public class DBOpenHelper extends SQLiteOpenHelper {
    private static final String DBNAME = "aiju.db";
    private static final int VERSION = 1;

    /**
     * 构造器
     *
     * @param context
     */
    public DBOpenHelper(Context context) {
        super(context, DBNAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("DROP TABLE IF EXISTS good");
        db.execSQL("CREATE TABLE IF NOT EXISTS good (id integer primary key autoincrement, " +
                "goodid varchar(20), " +
                "name varchar(20), " +
                "code varchar(20), " +
                "price varchar(20), " +
                "unit varchar(20), " +
                "goodstypeid varchar(20), " +
                "imageurl varchar(100), " +
                "selectsum INTEGER)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS good");
        onCreate(db);
    }
}